#ifndef SAMPLEGRABBER_HPP
#define SAMPLEGRABBER_HPP

#ifdef WIN32
#ifdef BUILD_CPCAP_DLL
#define EXPORT_DLL __declspec(dllexport)
#else
#define EXPORT_DLL __declspec(dllimport)
#endif
#else
#define EXPORT_DLL
#endif

#ifdef WIN32
#ifdef USE_QOBJECT
#include <QObject>
#endif
#include <mdshow.hpp>
typedef unsigned int uint;
#include <time.h>
#ifdef USE_QOBJECT
class EXPORT_DLL SampleGCB : public QObject, public ISampleGrabberCB
{
    Q_OBJECT
#else
class EXPORT_DLL SampleGCB : public ISampleGrabberCB
{
#endif
public:
    SampleGCB();
    ~SampleGCB();
    STDMETHODIMP SampleCB(double, IMediaSample *pSample);
    STDMETHODIMP BufferCB(double, BYTE *, long);
    STDMETHODIMP QueryInterface(REFIID riid, void **ppvObject);
    STDMETHODIMP_(ULONG) AddRef();
    STDMETHODIMP_(ULONG) Release();

    void   setSize(uint _w, uint _h);
    void   negate();
    void   enableFiltering(bool enabled);
    void   enableSegmentation(bool enabled);
    double getFPS();

private:
    long           nBytes;
    double         fps;
    time_t         last;
    unsigned char *imgdata;
    int            width;
    int            height;
    bool           inverted;

    void copyBitsRGB(unsigned char *pixels);
    CRITICAL_SECTION cSection;
#ifdef USE_QOBJECT
signals:
    void sendFrame(unsigned char *,int,int,int,int,unsigned int);
#endif
};
#endif

#endif // SAMPLEGRABBER_HPP
